package com.iss.airsys.dao;

import com.iss.airsys.entity.Userinfo;
import com.iss.airsys.model.UserinfoWithUserWithRole;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UserInfoDao {
    //增
    @Insert("insert into userinfo values(null,#{uInfo_familyname},#{uInfo_gender},#{uInfo_phone},#{uInfo_name})")
    Integer insertPeople(Userinfo userinfo);
    //删
    @Delete(" <script>"+"delete from userinfo where uInfo_name in" +
            "    <foreach collection=\"array\" item=\"id\" separator=\",\" open=\"(\" close=\")\">" +
            "        #{id}" +
            "    </foreach></script>")
    Integer deletePeople(String[]uInfo_names);
    //改
    @Update("update userinfo set uInfo_id=null,uInfo_familyname=#{uInfo_familyname},uInfo_gender=#{uInfo_gender},uInfo_phone=#{uInfo_phone} where uInfo_name=#{uInfo_name}")
    Integer updatePeople(Userinfo userinfo);
    //查
    @Select("select uInfo_id,uInfo_familyname,uInfo_gender,uInfo_phone,uInfo_name,u_pwd,u_roleid,r_name  from userinfo inner join user on user.u_name=userinfo.uInfo_name inner join userrole on userrole.r_id=user.u_roleid")
    List<UserinfoWithUserWithRole> selectAll();
    //根据id查询
    @Select("select * from userinfo where uInfo_name=#{uInfo_name}")
    Userinfo selectUserinfobyName(String uInfo_name);
}
